﻿using System;
using CDOP.Model;

namespace CDOP.UserControls
{
    public partial class UcMedicalHistory : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void AddObjectValues(ref MasterTable recordToFill)
        {
            if (txtBirthWeight.Text != string.Empty)
                recordToFill.Birth_weight = float.Parse(txtBirthWeight.Text);
            if (txtNumberOfMultipleBirths.Text != string.Empty)
                recordToFill.Multiple_Birth_Number = Convert.ToInt32(txtNumberOfMultipleBirths.Text);
            recordToFill.Multiple_Birth = ddMultipleBirth.SelectedItem.Text;
            recordToFill.Medical_Conditions_Death = ddMedicalConditionsDeath.SelectedItem.Text;
            recordToFill.Medical_Conditions_Death_Details_1 = txtMedicalConditionsDeathDetails01.Text;
            recordToFill.Medical_Conditions_Death_Details_2 = txtMedicalConditionsDeathDetails02.Text;
            recordToFill.Delays_Impairments_Disabilities_Death = ddDelaysImpairmentsDisabilitiesDeath.SelectedItem.Text;
            recordToFill.Delays_Impairments_Disabilities_Death_Details = txtDelaysImpairmentsDisabilitiesDeath.Text;
            recordToFill.Other_Notes = txtOtherNotes.Text;
        }

        public void LoadObjectValues(ref MasterTable recordToFill)
        {
            if (recordToFill.Birth_weight != null)
                txtBirthWeight.Text = recordToFill.Birth_weight.ToString();
            if (recordToFill.Multiple_Birth_Number != null)
                txtNumberOfMultipleBirths.Text = recordToFill.Multiple_Birth_Number.ToString();
            if (ddMultipleBirth.Items.Count == 0)
                ddMultipleBirth.DataBind();
            ddMultipleBirth.SelectedIndex = ddMultipleBirth.Items.IndexOf(ddMultipleBirth.Items.FindByText(recordToFill.Multiple_Birth));
            if (ddMedicalConditionsDeath.Items.Count == 0)
                ddMedicalConditionsDeath.DataBind();
            ddMedicalConditionsDeath.SelectedIndex = ddMedicalConditionsDeath.Items.IndexOf(ddMedicalConditionsDeath.Items.FindByText(recordToFill.Medical_Conditions_Death));
            txtMedicalConditionsDeathDetails01.Text = recordToFill.Medical_Conditions_Death_Details_1;
            txtMedicalConditionsDeathDetails02.Text = recordToFill.Medical_Conditions_Death_Details_2;
            if (ddDelaysImpairmentsDisabilitiesDeath.Items.Count == 0)
                ddDelaysImpairmentsDisabilitiesDeath.DataBind();
            ddDelaysImpairmentsDisabilitiesDeath.SelectedIndex = ddDelaysImpairmentsDisabilitiesDeath.Items.IndexOf(ddDelaysImpairmentsDisabilitiesDeath.Items.FindByText(recordToFill.Delays_Impairments_Disabilities_Death));
            txtDelaysImpairmentsDisabilitiesDeath.Text = recordToFill.Delays_Impairments_Disabilities_Death_Details;
            txtOtherNotes.Text = recordToFill.Other_Notes;
        }
    }
}